<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <img id="img" th:src="@{#}" alt="验证码图片" title="点击更换验证码">
</body>
<script th:src="@{https://code.jquery.com/jquery-3.7.0.js}"></script>
<script>
    $(function (){
        let src = "/getVerificationCode?" + new Date().getTime(); //加时间戳，防止浏览器利用缓存
        $('#img').attr('src',src);
    });
</script>
</html>